﻿//-----------------------------------------------------------------
//
// @(#)$Id: Orders.aspx.cs,v 1.0 2013/12/13 17:55:57 lichunhua Exp $
// @(#)$Author: lichunhua  $
// @(#)$Date: 2013/12/13 17:55:57 $
// @(#)$Description:
//
//
//
//                 All Rights Reserved.
//-----------------------------------------------------------------
using System;
using System.Data;
using System.Web.UI.WebControls;
using ebay.Dal;
using ebay.Dal.CenterDB_BasTableAdapters;
using ebay.Dal.CenterDB_EbayTableAdapters;
using ebay.Dal.CenterDB_OrderTableAdapters;

public partial class UI_Orders_Orders : System.Web.UI.Page
{


    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        T_EbayAccountTableAdapter ebayAccountAdapter = new T_EbayAccountTableAdapter();
        ddlebayUserId.DataSource = ebayAccountAdapter.GetData();
        ddlebayUserId.DataTextField = "EbayUserId";
        ddlebayUserId.DataValueField = "EbayUserId";
        ddlebayUserId.DataBind();
        ddlebayUserId.Items.Insert(0, new ListItem("《--请选择--》", " "));
        beginDate.Value = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00";
        endDate.Value = DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59";

        xdbeginDate.Value = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd") + " 00:00:00";
        xdendDate.Value = DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59";


        xgbeginDate.Value = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00";
        xgendDate.Value = DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59";

        //T_RefundTypeTableAdapter rTypeAdapter = new T_RefundTypeTableAdapter();
        //ddltkrefType.DataSource = rTypeAdapter.GetData();
        //ddltkrefType.DataValueField = "Id";
        //ddltkrefType.DataTextField = "RefundType";
        //ddltkrefType.DataBind();

        //ddltkdisputeStatus.Items.Insert(0, new ListItem("未投诉", "0"));
        //ddltkdisputeStatus.Items.Insert(0, new ListItem("已投诉", "1"));

        //T_DepartMentTableAdapter dAdapter = new T_DepartMentTableAdapter();
        //ddltkdepartment.DataSource = dAdapter.GetData();
        //ddltkdepartment.DataValueField = "FitemId";
        //ddltkdepartment.DataTextField = "FName";
        //ddltkdepartment.DataBind();

        T_OrderStatusTableAdapter oAdapter = new T_OrderStatusTableAdapter();
        ddlOrderStatusId.DataSource = oAdapter.GetData();
        ddlOrderStatusId.DataValueField = "StatusId";
        ddlOrderStatusId.DataTextField = "StatusName";
        ddlOrderStatusId.DataBind();
        ddlOrderStatusId.Items.Insert(0, new ListItem("《--请选择--》", " "));

        T_FZRTableAdapter FZR = new T_FZRTableAdapter();
        ddlFZR.DataSource = FZR.GetData();
        ddlFZR.DataValueField = "FItemID";
        ddlFZR.DataTextField = "FName";
        ddlFZR.DataBind();
        ddlFZR.Items.Insert(0, new ListItem("《--请选择--》", ""));

        //批量修改中的订单状态
        ddlStatusId.Items.Insert(0, new ListItem("《--请选择--》", " "));
        ddlStatusId.Items.Insert(1, new ListItem("未审核", "1"));
        ddlStatusId.Items.Insert(2, new ListItem("保留", "3"));
        ddlStatusId.Items.Insert(3, new ListItem("作废", "4"));
        ddlStatusId.DataBind();

        //订单标准化状态
        ddlStandard.Items.Insert(0, new ListItem("《--请选择--》", "Select"));
        ddlStandard.Items.Insert(1, new ListItem("解析正确", "解析正确"));
        ddlStandard.Items.Insert(2, new ListItem("金额不对", "金额不对"));
        ddlStandard.Items.Insert(3, new ListItem("无商品信息", "在系统中找不到相应的商品信息，请修正商品信息"));
        ddlStandard.Items.Insert(4, new ListItem("不完全代码"));
        //ddlStandard.Items.Insert(5, new ListItem("发货方式为空"));
        ddlStandard.Items.Insert(5, new ListItem("留言"));
        ddlStandard.Items.Insert(6, new ListItem("手工清除标准化"));
        ddlStandard.Items.Insert(7, new ListItem("Check Country"));
        ddlStandard.Items.Insert(8, new ListItem("包含禁用产品"));
        ddlStandard.DataBind();

        T_ExpressShippingMethodsTableAdapter shippingAdapter = new T_ExpressShippingMethodsTableAdapter();
        ddlDeliveryId.DataSource = shippingAdapter.GetData();
        ddlDeliveryId.DataTextField = "Delivery";
        ddlDeliveryId.DataValueField = "id";
        ddlDeliveryId.DataBind();
        ddlDeliveryId.Items.Insert(0, new ListItem("《--请选择--》", " "));

        //ddlDeliveryId2.DataSource = shippingAdapter.GetData();
        //ddlDeliveryId2.DataTextField = "Delivery";
        //ddlDeliveryId2.DataValueField = "id";
        //ddlDeliveryId2.DataBind();
        //ddlDeliveryId2.Items.Insert(0, new ListItem("《--请选择--》", ""));

        //仓库编号
        //T_StockTableAdapter stockAdapter = new T_StockTableAdapter();
        //ddlWarehouseId.DataSource = stockAdapter.GetData();
        //ddlWarehouseId.DataTextField = "FName";
        //ddlWarehouseId.DataValueField = "FItemId";
        //ddlWarehouseId.DataBind();

        txtHandleDate.Value = DateTime.Now.ToString("yyyy-MM-dd");

    }
    protected void btnOrderPingZheng_Click(object sender, EventArgs e)
    {
        Session["OrderPingZheng"]=txtOrderPingZheng.Value;
        Response.Redirect("Certificate.aspx");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        WebUtility.CheckRight();
    }

    protected void btnExpore_Click(object sender, EventArgs e)
    {
        string ebayUserId = ddlebayUserId.Value.Trim();
        string orderId = txtOrderId.Value.Trim();
        string BuyerId = txtBuyerId.Value.Trim();
        string BuyerName = txtBuyerName.Value.Trim();
        string NewOrderId = txtNewOrderId.Value.Trim();
        string OrderStatusId = ddlOrderStatusId.Value.Trim();
        string Standard = ddlStandard.Value.Trim();
        string ResendReason = txtResendReason.Value.Trim();
        string itemId = txtItemId.Value.Trim();
        string userCode = txtUserCode.Value.Trim();
        string reason = txtRetentionReson.Value.Trim();
        string FZR = ddlFZR.Value.Trim();
        string qtype = "0";
        string resend = "false";
        string memo = "0";
        string DE = "0";
        //if (chkquantity)
        //{
        //    qtype = "1";
        //}
        //else
        //{
        //    qtype = "0";
        //}

        //if (chkresend)
        //{
        //    resend = "true";
        //}
        //else
        //{
        //    resend = "false";
        //}

        //if (chkmemo)
        //{
        //    memo = "1";
        //}
        //else
        //{
        //    memo = "0";
        //}

        //if (chkDE)
        //{
        //    DE = "1";
        //}
        //else
        //{
        //    DE = "0";
        //}                
        bool s = rppei.Checked;
        bool s2 = rxdan.Checked;
        bool s3 = rxgai.Checked;
        string rtype = "1";
        string timeFrom;
        string timeTo;
        if (s)
        {
            rtype = "1";
            timeFrom = beginDate.Value;
            timeTo = endDate.Value;
        }
        else if (s2)
        {
            rtype = "2";
            timeFrom = xdbeginDate.Value;
            timeTo = xdendDate.Value;
        }
        else
        {
            rtype = "3";
            timeFrom = xgbeginDate.Value;
            timeTo = xgendDate.Value;
        }
        Report rt = new Report();
        DataTable table = rt.GetEbaySelling(ebayUserId, timeFrom, timeTo, orderId, BuyerId, BuyerName, NewOrderId, OrderStatusId, Standard, rtype, itemId, userCode, reason, qtype, resend, memo,   ResendReason, FZR, DE);

        int tc = table.Rows.Count;
        if (tc > 0)
        {
            DataSetToExcel.DataSetOutExcel(table, "EbaySelling");           
        }
        else
        {
            WebUtility.ShowMsg("无数据", this);
        }
    }
}
